package com.itheima.day14.day14work4;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test1 {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                3,
                5,
                3, TimeUnit.SECONDS,
                 new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );

        for (int i=0;i<8;i++) {//.RejectedExecutionException 超出线程池和队列的最高承载报异常
            executor.submit(()-> System.out.println(Thread.currentThread().getName()+"在执行"));
        }
        executor.shutdown();
    }
}
